<template>
  <div>
    <el-form v-loading="loading" :model="dataForm" label-position="left" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="检测结果">
      <el-tag type="warning">等待认证</el-tag>
      <!-- <el-tag type="success" v-if="dataForm.status == 1">完成认证</el-tag> -->
    </el-form-item>
    <el-form-item label="权限等级" >
      <el-tag v-if="dataForm.level == 1">免费使用</el-tag>
      <el-tag v-if="dataForm.level == 2">按量付费</el-tag>
      <el-tag v-if="dataForm.level == 3">按月付费</el-tag>
    </el-form-item>
    <el-form-item label="用户名" >
      <el-input v-model="dataForm.username" placeholder="用户名" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="邮箱" >
      <el-input v-model="dataForm.email" placeholder="邮箱" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="验证码" prop="ckey">
      <el-input v-model="vcode" placeholder="邮箱验证码"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dataFormSubmit()">提交验证码</el-button>
    </span>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        loading:false,
        vcode:"",//验证码
        levelText:"",
        statusText:"",
        readSwitch: true,
        // dataForm: this.dataFormParent,
        dataRule: {
          ckey: [
            { required: true, message: '用户名不能为空', trigger: 'blur' }
          ],
        },
      }
    },
    props:['dataForm'],
    methods: {
      // 表单提交
      dataFormSubmit () {
        this.loading = true;
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              async:true,
              url: this.$http.adornUrl(`/product/consumer/reg/checkcode/${this.dataForm.consumerId}`),
              method: 'post',
              data: this.$http.adornData({
                'vcode': this.vcode
              })
            }).then(({data}) => {
                if (data && data.code === 0) {
                    this.$message({
                        message: "完成验证",
                        type: "success"
                    });
                    this.$emit("changeStep",3);
                }else{
                    this.$message({
                        message: data.msg,
                        type: "warning"
                    });
                }
                 this.loading = false;

            })
// this.$emit("changeStep",3);
          }
        })
      }
    }
  }
</script>
